﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using ProcessControl;
using MyLib;
using System.Data;

namespace OtherContract
{
    public partial class NewRequest : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {

          // ((ButtonList)ButtonList1).BeforeSubmit += new System.ComponentModel.CancelEventHandler(NewRequest_BeforeSubmit);
        }
        //
        void NewRequest_BeforeSubmit(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //try
            //{
            //    string useraccount = Page.User.Identity.Name.Split('\\')[1].ToString();
            //    string contractNo = "";
            //    DataTable dt = DataAccess.Instance("BizDB").ExecuteDataTable("select * from V_EMPDEPARTMENTS t  where employeeid='" + useraccount + "'");
            //    if (dt.Rows.Count > 0)
            //    {
            //        string departmentid = dt.Rows[0]["departmentid"].ToString();
            //        do
            //        {
            //            DataTable dt1 = DataAccess.Instance("BizDB").ExecuteDataTable("select * from  v_department where departmentid='" + departmentid + "'");
            //            if (dt1.Rows.Count > 0)
            //            {
            //                string cocentre = dt1.Rows[0]["departmentname"].ToString();
            //                departmentid = dt1.Rows[0]["parentid"].ToString();
            //                if (dt1.Rows[0]["parentid"].ToString() != dt1.Rows[0]["departmentid"].ToString())
            //                {
            //                    switch (cocentre.Substring(0, cocentre.IndexOf('[')))
            //                    {
            //                        case "服务中心":
            //                            contractNo = "FW";
            //                            break;
            //                        case "咨询中心":
            //                            contractNo = "ZX";
            //                            break;
            //                        case "软件中心":
            //                            contractNo = "RJ";
            //                            break;
            //                        case "工程中心":
            //                            contractNo = "GC";
            //                            break;
            //                        case "技术中心":
            //                            contractNo = "JS";
            //                            break;
            //                        case "运营管理中心":
            //                            contractNo = "YY";
            //                            break;
            //                        case "国际服务部":
            //                            contractNo = "GJ";
            //                            break;
            //                        case "采购部":
            //                            contractNo = "CG";
            //                            break;
            //                        default:
            //                            contractNo = "";
            //                            break;
            //                    }
            //                }
            //                else
            //                {
            //                    contractNo = "NO";
            //                }
            //            }
            //        else
            //        {
            //        contractNo = "NO";
            //        }
            //        }
            //        while (contractNo == "");
            //    }
            //    if (contractNo != "NO")
            //    {
            //        fld_TCONTRACTNO.Text = GetTBELONGMAIN(fld_TBELONGMAIN.SelectedItem.Text) + "-" + contractNo + "-" + GetTBUSSNIESSTYPE(fld_TBUSSNIESSTYPE.SelectedItem.Text) + "-" + (DateTime.Now.Year - 2000).ToString();
            //    }
            //}
            //catch (Exception ex)
            //{
            //    throw new NotImplementedException();
            //}
        }

        //获得主体代码
        public string GetTBELONGMAIN(string fld_TBELONGMAIN)
        { 
            string str="";
          switch(fld_TBELONGMAIN)
            {
                  case"新疆金风科技股份有限公司":
                  str="BJTYS";
                  break;
                  case"北京金风科创风电设备有限公司":
                  str="BJKCS";
                  break;
                  case"北京天源科创风电技术有限责任公司":
                  str="XJGWS";
                  break;
                  case"软件公司":
                  str="RJGSS";
                  break;
                  default :
                  break;
            }
          return str;
        }

        public string GetTBUSSNIESSTYPE(string fld_TBUSSNIESSTYPE)
        { 
         string str="";
         switch (fld_TBUSSNIESSTYPE)
         {
                 case"设备物资":
                 str="SBWZ";
                 break;
                 case"材料销售":
                 str="CLXS";
                 break;
                   case"产品销售":
                 str="CPXS";
                 break;
                   case"测风咨询":
                 str="CFZX";
                 break;
                   case"硬件销售":
                 str="YJXS";
                 break;
                   case"软件销售":
                 str="RJXS";
                 break;
                   case"协议订单":
                 str="XYDD";
                 break;
             case"技术服务合同":
                 str="JSFW";
                 break;
             default:
                 break;
         }
         return str;
        }

        
    }
}